package com.leizhou.user.controller;

import com.leizhou.user.pojo.User;
import com.leizhou.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LT
 * @version 1.0.0
 * @ClassName UserController.java
 * @Description TODO
 * @createTime 2020年04月23日 11:06:00
 */
@RestController
@RequestMapping("/user")
@RefreshScope  // 刷新配置
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${test.name}")
    private String name;

    /**
     * 根据主键id查询用户
     */
    @GetMapping("/{id}")
    public User findOne(@PathVariable("id") Long id) {
        System.out.println("配置文件中的test.name = " + name);
        return userService.findOne(id);
    }
}